package flc.ast.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.picselect.entity.SelectMediaEntity;

import flc.ast.R;
import flc.ast.bean.SelectFileBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class PictureRecordAdapter extends StkProviderMultiAdapter<SelectFileBean> {


    public PictureRecordAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new PictureRecordProvider());
    }


    private boolean isEdit = true;

    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private class PictureRecordProvider extends BaseItemProvider<SelectFileBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_picture;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectFileBean bean) {
            Glide.with(getContext()).load(bean.getPath())
                    .into((ImageView) baseViewHolder.getView(R.id.ivSelPictureItemImg));
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivSelPictureItemSel, R.drawable.axuanzhong);
            } else {
                baseViewHolder.setImageResource(R.id.ivSelPictureItemSel, R.drawable.aweixuanzhong2);
            }
            if (isEdit) {
                baseViewHolder.getView(R.id.ivSelPictureItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivSelPictureItemSel).setVisibility(View.GONE);
            }
        }
    }

}
